import Tween from './tween'
export default class timer {
  constructor () {
    this.time = 0
    this.frameCount = 0
    this.timePast = 0
    this.delta = 0
    this.sysTime = this.getSysTime()
    this.delayBuff = []
    this.intervalBuff = []
    this.tween = new Tween()
  }
  newTween(last, obj, target, easing, func){
    return this.tween.newTween(last, obj, target, easing, func)
  }
  getSysTime() {
    this.dateObj = new Date()
    return this.dateObj.getTime()
  }
  step() {
    this.frameCount += 1
    var newTime = this.getSysTime()
    this.delta = newTime - this.sysTime
    this.sysTime = newTime
    this.timePast += this.delta
    return this.delta
  }
  getDelta(){
    return this.delta
  }
  getFPS(){
    return 1000/this.delta
  }
  setFPS(num){
    return wx.setPreferredFramesPerSecond(num)
  }
  delay(time,func){
    return setTimeout(func, time)
  }
  interval(time,func){
    return setInterval(func, time)
  }
  clearDelay(id){
    return clearTimeout(id)
  }
  clearInterval(id){
    return clearInterval(id)
  }
}